<?php
namespace BoxAdmin\Controller;

use Think\Controller;

class AreaController extends Controller
{

    /*****选择地址**/
    public function getAreaChilds()
    {
        $success = false;
        $error = '';
        $data = array();
        $pid = I('pid');
        if ($pid == '') {
            $error = '参数错误';
        } else {

            $area = BoxModel("SystemArea");
            $data = $area->Childs($pid);
            $success = true;
        }
        echo json_encode(array('success' => $success, 'data' => $data, 'error' => $error));
        exit();
    }

    /*****选择地址**/
    public function getAreaReverse()
    {
        $success = false;
        $error = '';
        $data = array();
        $pid = I('aid');
        if ($pid == '') {
            $error = '参数错误';
        } else {
            $area = BoxModel("SystemArea");
            $area_data = $area->load($pid);
            //dump($area_data);
            $data = array('provinceID' => $area_data['parent']['parent']['id'], 'cityID' => $area_data['parent']['id'], 'countyID' => $area_data['id']);
            $success = true;
        }
        echo json_encode(array('success' => $success, 'data' => $data, 'error' => $error));
        exit();
    }


}

?>